
<?php
    if(isset($_GET['id'])){
        $id = $_GET['id'];
        
        $bidjob = Bidjob::model()->findAll("user_id=$id", array('order'=>'user_id'));
        
        ?>
        
        <div id="content">
            <div class="fixed">
                <div class="job_detail" >
                <?php
                    echo "Ho ten : " . $model->name . "</br>";
                    echo "Email : " . $model->email . "</br>";
                    echo "So cong viec : " . count($bidjob). "</br>";    
                ?>

            </div> <!--end job_detail-->
            
            <div id="main_content" class="fixed clear">
                <span class="col_title">Status</span>
                <table class="job_list" width="100%">
                    <thead>
                        <th width="40%">Ten Cong Viec  </th>
                        <th width="30%">Trang Thai Cong Viec  </th>
                        <th width="30%">View Profiles  </th>
                    </thead>
                   
<?php
                        foreach ($bidjob as $bidJob){
                            $b = $bidJob->job_id;
                            
                            /**Lay du lieu bang job*/
                            $job = Job::Model()->findAll(array(
                            'condition'=>"id = $b",
                            ));
                            /**show status cua job ung voi moi id*/
                            foreach($job as $Job){
?>
                        <tbody> <!--start tbody-->
                        
                            <td align="center"><?php echo $Job->name ?></td><!--td 1-->
                            
                        <?php
                        
                                $userIdJob = $Job->user_id;
                        ?>
                        
                        
                        <td align="center"> <!--td 2-->
                        <?php 
                            switch ($Job->status){
                                    case 1 : echo "Chua hoan thanh";break;
                                    case 2 : echo "Sap hoan thanh";break;
                                    case 3 : echo "Da hoan thanh";break;
                                }
                        ?>
                        
                        </td><!--end td 2-->
                        
                        
                        
                                <?php
                                $userprofiles = UserProfiles::Model()->findAll(array(
                                'condition'=>"user_id = $userIdJob",
                                ));
                                
                                $sumView = 0;
                                foreach($userprofiles as $userProfiles){
                                    $sumView = $sumView + (double)$userProfiles->viewed;
                                }
                                ?>
                                
                        <td align="center"><!--td 3-->
                                    <?php
                                        echo $sumView;
                                    ?>
                        </td>
                        
                        </tbody><!--end tbody-->
<?php
                            }
                        }
?>            
                </table> <!--end table-->
                
                </div><!--end div main_content-->
        	
        </div><!--end fixed-->
           
    </div><!--end content-->
    
    <?php }
    else{
        echo "khong ton tai ";
    }
    ?>
        
        